package com.itheima.mapper;

import com.itheima.domain.pojo.Emp;
import com.itheima.domain.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

//    ///@Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id")
//    List<Emp> list(String  name, Integer gender, LocalDate begin, LocalDate end);
    List<Emp> list(EmpQueryParam empQueryParam);
    @Select("select count(*) from emp e left join dept d on e.dept_id = d.id ")
    Long count();

    //添加员工信息
    @Insert("insert into emp(username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) " +
            "values(#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void insert(Emp emp);
    //查询全部员工信息
    @Select("select id,username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time from emp ")
    List<Emp> niager();

    void deleteByIds(List<Integer> ids);

    void updateById(Emp emp);

    Emp getById(Integer id);

    @MapKey("pos")
    List<Map<String, Object>> countEmpJobData();

    @MapKey("job")
    List<Map<String, Object>> getEmpSalaryData();

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getUsernameAndPassword(Emp emp);
}